﻿using System;
using System.Collections.Generic;
using System.Text;
using KKCai.App.DAL;
using KKCai.App.Model;

namespace KKCai.App.BLL
{
    public class NewsManager
    {
        private NewsDao _dao = new NewsDao();

        #region CRUD

        public NewsInfo Save(NewsInfo info)
        {
            return _dao.Save(info);
        }

        public NewsInfo Update(NewsInfo info)
        {
            _dao.Update(info);

            _dao.CommitChanges();

            return info;
        }

        public NewsInfo Get(int id)
        {
            return _dao.Get(id);
        }

        public void Delete(NewsInfo info)
        {
            _dao.Delete(info);

            _dao.CommitChanges();
        }
        #endregion

        public IList<NewsInfo> Show(int tid, int start, int limit)
        {
            return _dao.ShowByType(tid, start, limit);
        }

        public IList<NewsInfo> Show(int tid, int start, int limit, out int count)
        {
            count = _dao.CountByType(tid);

            return _dao.ShowByType(tid, start, limit);
        }

        public IList<NewsInfo> List(int start, int limit, out int count)
        {
            count = _dao.GetCount();

            return _dao.Order("id", false, start, limit);
        }
    }
}
